package main

import "sort"

func main() {

}

//#link: https://leetcode-cn.com/problems/rectangle-area/
func computeArea(ax1 int, ay1 int, ax2 int, ay2 int, bx1 int, by1 int, bx2 int, by2 int) int {
	total := (ax2-ax1)*(ay2-ay1) + (bx2-bx1)*(by2-by1)
	//判断是否有重复区域
	if ax2 < bx1 || ay1 > by2 || ax1 > bx2 || ay2 < by1 {
		return total
	}
	x := []int{ax1, ax2, bx1, bx2}
	y := []int{ay1, ay2, by1, by2}
	sort.Ints(x)
	sort.Ints(y)
	return total - (x[2]-x[1])*(y[2]-y[1])

}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
